﻿<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<x:parse xml="${param.xmlstr}" var="xmlData" />
<input type="hidden" name="proposal/cooperation_units1" id="cooperation_units1" value="<x:out select='$xmlData/data/proposal/cooperation_units1'/>"/>
<input type="hidden" name="proposal/cooperation_unit1" id="cooperation_unit1" value="<x:out select='$xmlData/data/proposal/cooperation_unit1'/>"/>

<div class="t_bar"><span class="color_red">*</span>牵头单位和合作单位分工（除申报单位外，合作单位限制最多5个） </div>
<table id="compareWork" border="0" cellspacing="0" cellpadding="0" style="width: 100%" class="table01 t_css">
    <thead>
    <tr>
        <th align="center" width="5%">选择</th>
        <th align="center" width="5%">序号</th>
        <th align="center" width="40%">单位</th>
        <th align="center" width="50%">分工</th>

    </tr>
    </thead>
    <tbody id="land_tab">
    <tr style="display: none" align="center">
        <td align="center">
            <input type="radio" class="radiobutton" name="selAttendOrg11">
        </td>
        <td align="center">
            <span name="lands|land[0]@seq_no">[index]</span>
        </td>
        <td align="center">
            <input name="lands|land[0]|org_name" label="单位" type="text" onchange="setCooperationUnits1();setCooperationUnit1();" required class="input_css required maxlength:300" style="width: 80%;" maxlength="100" value="" />
        </td>

        <td align="center">
            <input name="lands|land[0]|division" label="分工" type="text" required class="input_css required maxlength:300" style="width: 80%;" maxlength="100" value="" />
        </td>
    </tr>
    <c:set value="0" var="index" scope="page" />
    <x:forEach select="$xmlData/data/lands/land" var="land">
        <c:choose>
            <c:when test="${index<10}">
                <c:set value="0" var="flag" scope="page" />
            </c:when>
            <c:otherwise>
                <c:set value="" var="flag" scope="page" />
            </c:otherwise>
        </c:choose>
        <tr align="center">
            <td>
                <input type="radio" class="radiobutton" name="selAttendOrg11">
            </td>
            <td align="center">
					<span name="lands/land[${flag}${index}]@seq_no">
						<x:out select="$land/@seq_no" />
					</span>
            </td>
            <td>
                <input name="lands/land[${flag}${index}]/org_name" onchange="setCooperationUnits1();setCooperationUnit1();" label="单位" type="text" required class="input_css required maxlength:100" style="width: 80%;" maxlength="100"
                       value="<x:out select="$land/org_name" />" />
            </td>

            <td align="center">

                <input name="lands/land[${flag}${index}]/division" label="分工" type="text" required class="input_css required maxlength:300" style="width: 80%;" maxlength="100"
                       value="<x:out select="$land/division" />" />
            </td>
        </tr>
        <c:set value="${index+1}" var="index" scope="page" />
    </x:forEach>
    </tbody>
</table>
<table width="100%" class="not_table">
    <tr>
        <td>
            <input class="button_02" type="button" name="cmdAddbefore" value="添加" onclick="if(checkTabLimit('compareWork',6,'牵头单位和合作单位分工最多只能填写6条')){addNewRow('compareWork');}try{top.resizeFrame();}catch(e){};" />
            <input class="button_02" name="cmdMovePrev" type="button" value="上移" onclick="movePrev('compareWork');setCooperationUnits1();setCooperationUnit1();" />
            <input class="button_02" name="cmdMoveNext" type="button" value="下移" onclick="moveNext('compareWork');setCooperationUnits1();setCooperationUnit1();" />
            <input class="button_02" name="cmddel" type="button" value="删除" onclick="deleteSelectedRow('compareWork','牵头单位和合作单位分工');setCooperationUnits1();setCooperationUnit1();" />
        </td>
    </tr>
</table>

<div class="t_bar">备注 (限500字)</div>
<table class="t_css" width="100%" border="0" cellspacing="0" cellpadding="0" id="tblresume">
    <tr class="li_2">
        <td>
		  <textarea name="project/summary99" style="width:98%" class="input_textarea  maxlength:500"
                    label="备注" rows=5 cols=60><x:out select="$xmlData/data/project/summary99"/></textarea>
            <input type="hidden" name="project/summary99_hidden" id="project/summary99_hidden"
                   value="<x:out select="$xmlData/data/project/summary99" />"/>
        </td>
    </tr>

</table>

<script>
    function isBlankOrNull(str){
        if(str.trim()==""){
            return true;
        }else if(str){
            return false;
        }else{
            return true;
        }
    }
    function deleteSelectedRow(tableId,message,nummin,warnMsg,selName){
        if(!selName)selName="";
        var tr=$("#"+tableId+" :radio[name*='"+selName+"']:checked").parents("tr");
        if(nummin==null)
            nummin=0;
        var length=tr.length;
        if(tr.length==0)
            tr=$("#"+tableId+" tr").filter(":last");
        else if(tr.length>1)
            tr=tr.first();

        if(tr.get(0).rowIndex-1==nummin){
            if(!!warnMsg){
                scmWarn(warnMsg);
            }else{
                scmWarn(irisNotes.delWarn1);
            }
            return false;
        }
        if(length==0){

            scmWarn(irisNotes.delWarn2);

            return false;
        }
        if(!confirm(messageTip.deleteTip+message+"？"))
            return false;
        tr.remove();

        refreshRowINdex(tableId);
        return true;
    }
    function setCooperationUnits1(){
        var cooperation_units1="";
        $("#compareWork tr:gt(1)").each(function(index){
            var cooperation_unit1 = $(this).find("td:eq(2) input").val().trim();
            var orgName = $("#org_name").val().trim();
            if(!isBlankOrNull(cooperation_unit1) && cooperation_unit1!=orgName){
                cooperation_units1 += cooperation_unit1+",";
            }
        });
        if(cooperation_units1!=""){
            cooperation_units1=cooperation_units1.substring(0,cooperation_units1.length-1);
        }
        $("#cooperation_units1").val(cooperation_units1);
    }
    function setCooperationUnit1(){
        var cooperation_unit1="";
        $("#compareWork tr:gt(1)").each(function(index){
            var cooperation_units1 = $(this).find("td:eq(2) input").val().trim();
            if(!isBlankOrNull(cooperation_units1) ){
                cooperation_unit1 += cooperation_units1+",";
            }
        });
        if(cooperation_unit1!=""){
            cooperation_unit1=cooperation_unit1.substring(0,cooperation_unit1.length-1);
        }
        $("#cooperation_unit1").val(cooperation_unit1);
    }

</script>